﻿<%@ WebHandler Language="C#" Class="GetVideo" %>

using System;
using System.Web;
using System.Text;
using System.Data;
using BusinessObjects.BO_GetObjects;
using System.IO;
using System.Xml;

public class GetVideo : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        StringBuilder strArticles = new StringBuilder();
        try
        {
            string fname = "http://digicorp.vn/upload/xml/video.xml";

            XmlDocument doc = new XmlDocument();
            doc.Load(fname);
            XmlNode root = doc.DocumentElement;
            XmlNodeList list = root.ChildNodes;
            //txtVideoName.Text = list.Item(0).InnerText;
            string link = list.Item(1).InnerText;
            string video_id = link.Substring(link.IndexOf("watch?v="), 19).Replace("watch?v=", "");
            strArticles.Append("{ Video:[");
            strArticles.Append("{");
            //strArticles.Append("\"Name\":\"" + dt.Rows[i]["PICTURE_NAME_VN"].ToString() + "\",");
            strArticles.Append("\"Link\":\"" + video_id + "\"");
        }
        catch (Exception ex)
        {

        }
        strArticles.Append("}");
        strArticles.Append("]}");
        context.Response.ContentType = "application/json";
        context.Response.ContentEncoding = System.Text.Encoding.UTF8;
        context.Response.Write(strArticles.ToString());
        context.Response.End();
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}